#pragma once

#include <map>
#include <vector>
#include "GalconCommonTypes.h"
#include "PlanetInternalImpl.h"
#include "PlayerInternalImpl.h"
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
#include "MessageFwd.h"

class GameState: private boost::noncopyable
{
public:
   
   typedef std::map<PlanetID, PlanetInternalImplPtr> PlanetsMap;
   typedef PlanetsMap::value_type PlanetsMapPair;
   typedef std::map<PlayerID, PlayerInternalImplPtr> PlayersMap;
   typedef PlayersMap::value_type PlayerMapPair;

public:
   
   GameState(unsigned int countOfPlanets, unsigned int countOfPlayers);

   GameState();

   ~GameState(void);

   void AddPlanet(PlanetID planetID, PlanetInternalImplPtr planetPtr);

   PlanetInternalImplPtr RemovePlanet(PlanetID planetID);

   PlanetInternalImplPtr GetPlanet(PlanetID planetID);

   void AddPlayer(PlayerID playerID, PlayerInternalImplPtr playerPtr);

   PlayerInternalImplPtr RemovePlayer(PlayerID playerID);

   PlayerInternalImplPtr GetPlayer(PlayerID playerID);

   void SetShipCount(PlanetID planetID, double count);


   double GetShipCount(PlanetID planetID) const;


   GameColors GetPlayerColor(PlayerID playerID) const
   {
      return m_players.at(playerID)->PlayerColor();
   }

   // updates count of ships on planets
   void UpdatePlanets();

   const PlanetsMap& GetPlanets()
   {
      return m_planets;
   }

   const PlayersMap& GetPlayers()
   {
      return m_players;
   }

private:

   void generateBeginingState(unsigned int, unsigned int);

   PlanetsMap m_planets;
   
   PlayersMap m_players;
};